
#ifndef _TSOC_PHOTON_
#define _TSOC_PHOTON_

#include "Math.hpp"
#include "Color.hpp"

#include <pthread.h>
#include <vector>
#include <stdint.h>

#define TSOC_PHOTON_PRIMARY	1

#define TSOC_PHOTON_DIRECT 	0
#define TSOC_PHOTON_DIFFUSE 	1
#define TSOC_PHOTON_SPECULAR	2


namespace com
{
	namespace toxiclabs
	{
		namespace tsoc
		{
			class Photon
			{
				public:
				
					Vector position;
					Vector direction;
					Vector normal;
					Color power;
					uint8_t type;
			};
						
			class PhotonMap
			{
				private:
					std::vector<Photon *>photons;
					pthread_mutex_t mutex_addphotons;
					
					Vector bb_min;
					Vector bb_max;
					
					float cell_size_x,cell_size_y,cell_size_z;
					std::vector<Photon*> hash [4096];
					
				public:
					
					PhotonMap();
					~PhotonMap();
					
					void AddPhotons(std::vector<Photon *> * photons);
					void Clear();
					void Build();
					int Search(Vector &position,Vector &normal,int type,float radius,Color  * out_power);
					int Size();
					int PrimarySize();
					
				
			};
		}
	}
}

#endif
